package com.imooc.sell.dao;

import com.imooc.sell.dataobject.OrderMaster;
import com.imooc.sell.dto.OrderDTO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Date;
import java.util.List;


public interface OrderMasterDao extends JpaRepository<OrderMaster, String> {
    /**
     * 通过用户id实现订单分页查询
     */
    Page<OrderMaster> findAllByBuyerOpenid(String openid, Pageable pageable);

    /**
     * 通过用户id查询其所有订单,不分页
     */
    List<OrderMaster> findAllByBuyerOpenidAndBuyerPhoneIsNotNullOrderByCreateTimeDesc(String openid);
    /**获取单个订单主表中的记录*/
    //OrderMaster findByOrderId(String orderId);

    /**
     * 通过订单支付状态分页查询 按照时间排序的订单列表
     */
    Page<OrderMaster> findAllByPayStatusOrderByCreateTimeDesc(Short payStatus, Pageable pageable);

    /**
     * 通过订单状态查询在日期范围内的订单，并按时间顺序排序
     */
    Page<OrderMaster> findAllByOrderStatusAndCreateTimeBetweenOrderByCreateTimeDesc(Short orderStatus, Date startDate, Date endDate, Pageable pageable);
}
